<template>
  <view class="content">
    <view class="center">
      <view class="title">{{ list.serviceName }}</view>
      <view class="msg" style="margin-top: 20rpx">
        <text class="nam">{{ list.userName }}</text>
        <text class="sex">{{ list.sex }}</text>
        <text class="age">{{ list.age }}</text>
      </view>
      <view class="time">
        <text>{{ list.createdAt }}</text>
      </view>
    </view>
    <view class="center" v-if="identity == 1">
      <view class="title">患者主述</view>
      <view class="desc line2">
        {{ list.principleAction }}
      </view>
    </view>
    <block v-if="isNullStatus == 1 && identity != 4">
      <view class="center" style="padding: 32rpx 40rpx 0 40rpx">
        <view class="title" style="margin-bottom: 10rpx">基础情况评估</view>
        <view class="sign" v-for="(item, index) in arr1" :key="index">
          <text class="title">{{ item.fieldName }}</text>
          <text class="msg">{{ listBasic[item.englishFieldName] }}</text>
        </view>
      </view>
      <view class="center" style="padding: 32rpx 40rpx 0 40rpx">
        <view class="title" style="margin-bottom: 10rpx">专项情况评估</view>
        <view class="sign" v-for="(item, index) in arr2" :key="index">
          <text class="title">{{ item.fieldName }}</text>
          <!-- 初始{{listBasic[item.englishFieldName]}} -->
          <span class="msg">
            {{ item.options[listBasic[item.englishFieldName]].name }}
            {{ listBasic[item.englishFieldName + 'Detail'] }}
          </span>
          <!-- 	<text class="msg" style="display: flex;flex-wrap: nowrap;">
						<span class="msg"
							v-if="listBasic[item.englishFieldName]-1>=0&&(item.englishFieldName!='allergyHistory')">
							{{item.options[listBasic[item.englishFieldName]-1].name}}
							{{listBasic[item.englishFieldName+'Detail']}}
						</span>

						<span class="msg" v-if="item.englishFieldName=='allergyHistory'" style="padding-left: 20rpx;">
							{{listBasic[item.englishFieldName+'Detail']}}
						</span>
						<span class="msg"
							v-if="listBasic[item.englishFieldName]-1<0&&(item.englishFieldName!='allergyHistory')">
							{{item.options[listBasic[item.englishFieldName]+1].name}}
							{{listBasic[item.englishFieldName+'Detail']}}
						</span>

						<span class="msg"
							v-if="listBasic[item.englishFieldName]-1<0&&item.englishFieldName=='allergyHistory'">
							{{item.options[listBasic[item.englishFieldName]].name}}
							{{listBasic[item.englishFieldName+'Detail']}}
						</span>
					</text> -->
        </view>
      </view>
    </block>
    <!-- 无内容 -->
    <block v-else>
      <view class="center" style="padding: 32rpx 40rpx 0 40rpx" v-if="identity == 1">
        <view class="title">体征检查</view>
        <view class="sign">
          <text class="title">体温（摄氏度）</text>
          <text class="msg">{{ list.animalHeat }}</text>
        </view>
        <view class="sign">
          <text class="title">脉搏（次/分）</text>
          <text class="msg">{{ list.sphygmus }}</text>
        </view>
        <view class="sign">
          <text class="title">呼吸（次/分）</text>
          <text class="msg">{{ list.breathe }}</text>
        </view>
        <view class="sign" style="border-bottom: none">
          <text class="title">血压（mmHg）</text>
          <text class="msg">{{ list.bloodPressure }}</text>
        </view>
      </view>
    </block>
    <view class="center">
      <view class="title" v-if="identity == 1">护理图片（5-10张）</view>
      <view class="title" v-else>护理图片（至少1张）</view>
      <view class="imgs" style="display: flex; justify-content: flex-start; flex-wrap: wrap" v-if="photo.length > 0">
        <image v-for="(item, index) in photo" :src="item" :key="index" mode="aspectFit" @click="clickImg(index)"> </image>
      </view>
    </view>

   
    <view class="center" v-if="identity == 1">
      <view class="title">护理内容</view>
      <view class="desc line2">
        {{ list.nursingContent }}
      </view>
    </view>
    <view class="center" v-if="identity == 1">
      <view class="title">健康指导</view>
      <view class="desc line2">
        {{ list.healthGuidance }}
      </view>
    </view>
  </view>
</template>

<script>
import { selectNursingRecordById, selectConfigurationByServiceId } from '@/apis/nurse-report/index.js'
export default {
  data() {
    return {

      id: '',
      list: {
        serveName: '',
        healthGuidance: '',
        animalHeat: '',
        sphygmus: '',
        breathe: '',
        bloodPressure: ''
      },
      photo: '',
      // 护理报告模版
      arr: [],
      arr1: [],
      arr2: [],
      isNullStatus: 0,
      listBasic: '',
      identity: 1
    }
  },
  computed: {

  },
  onLoad(option) {
    this.identity = this.$store.state.userInfo.identity
    console.log(this.$store.state.userInfo.identity)
    // console.log('111', option.id)
    this.id = option.id
    this.get()
  },
  onShow() {},
  // mounted:function(){
  // 	this.$nextTick(function(){
  // 		this.get()
  // 	})
  // },
  methods: {


    async get() {
      let id = this.id
      let res = await selectNursingRecordById({
        id
      })
      if (res.success) {
        // console.log('res888888888', res)
        for (let key in res.object) {
          if (!res.object[key]) {
            res.object[key] = '未填写'
          }
        }
        // 配置的字段
        selectConfigurationByServiceId({
          serviceId: res.object.serviceId
        }).then(r => {
          // console.log('rrrrrrrrrrrrrrrrrrrr', r)
          // console.log('r.object', r.object)
          if (r.object == null) {
            this.isNullStatus = 0
            this.$forceUpdate()
            // console.log('this.isNullStatus0000000000', this.isNullStatus)
          } else {
            this.isNullStatus = 1
            this.$forceUpdate()
            // console.log('this.isNullStatus111111111111', this.isNullStatus)
          }
          // 字段给arr
          this.arr = r.object
          // 初始化titlename
          this.initData()
        })
        this.list = res.object
        console.log('this.', this.list)

        if (res.object.staPictureUrl && res.object.endPictureUrl) {
          let arr = res.object.staPictureUrl.split(',')
          this.photo = [...arr]
        }
        this.listBasic = this.list.nursingRecord
        console.log('全部返回数据', this.list)
        // for (let i = 0; i < this.arr2.length; i++) {
        // 	console.log(11111111)
        // 	console.log('iiiiiiiooooooooooi', i.options[this.listBasic[i.englishFieldName]])
        // }
      }
    },
    //图片预览
    clickImg(index) {
      let _this = this
      wx.previewImage({
        urls: _this.photo,
        current: _this.photo[index], // 当前显示图片的http链接，默认是第一个
        success: function (res) {},
        fail: function (res) {},
        complete: function (res) {}
      })
    },
    initData() {
      this.list.animalHeat = this.$store.state.animalHeat
      this.list.sphygmus = this.$store.state.sphygmus
      this.list.breathe = this.$store.state.breathe
      this.list.bloodPressure = this.$store.state.bloodPressure
      let arr = this.arr.filter(r => r.isisDele != 1)
      arr.map(m => {
        if (m.fieldBelong != 1) {
          this.arr1.push(m)
          // this.list[m.englishFieldName] = ''
        } else {
          m.options = JSON.parse(m.choiceType)
          // m.options = arr1.map(a =>  {
          // 	return {
          // 		text:a.name,
          // 		value:a.value
          // 	}
          // })
          // console.log('m11111111111111111111', m)
          this.arr2.push(m)
        }
        return m
      })
      // console.log(this.arr1, 'arr1------')
      console.log(this.arr2, 'arr2------')
    }
  }
}
</script>

<style lang="scss" scoped>
.content {
  min-height: 100vh;
  background: rgba(243, 246, 246, 1);
  padding-top: 16rpx;
  box-sizing: border-box;
  padding-bottom: 40rpx;
}

.center {
  background-color: #ffffff;
  width: 100%;
  // height: 242rpx;
  padding: 32rpx 40rpx;
  // border-top: 1rpx solid rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  margin-bottom: 16rpx;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #666666;

  .imgs {
    image {
      width: 24%;
      height: 120rpx;
      margin-top: 24rpx;
      border-radius: 20rpx;
      margin-right: 4rpx;
    }
  }

  .video {
    position: relative;
    width: 24%;
    // max-height: 120rpx;
    margin-top: 24rpx;
    border-radius: 20rpx;
    margin-right: 4rpx;
    transition: width 0.3s ease;
    /* 设置过渡效果 */
    image {
      border-radius: 8rpx;
    }
  }

  .app_play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50rpx !important;
    height: 50rpx !important;
  }

  .fill {
    // transform: scale(1.2);
    // min-height: 120rpx;
    width: 50% !important;
    /* 图片放大到1.2倍 */
  }

  .title {
    height: 50rpx;
    font-size: 36rpx;
    line-height: 50rpx;
    font-size: 36rpx;
    font-weight: 500;
    color: #333333;
  }

  .samllTitle {
    height: 40rpx;
    font-size: 28rpx;
    line-height: 40rpx;
    margin-top: 24rpx;
    color: #333333;
  }

  .msg {
    height: 60rpx;
    height: 60rpx;
    line-height: 60rpx;
    font-size: 28rpx;
    line-height: 60rpx;

    text {
      margin-right: 24rpx;
    }
  }

  .time {
    height: 40rpx;
    font-size: 28rpx;
    line-height: 40rpx;

    text {
      margin-right: 8rpx;
    }
  }

  .desc {
    width: 672rpx;
    font-size: 28rpx;
    line-height: 40rpx;
    margin-top: 24rpx;
  }

  .flex {
    justify-content: space-between;
  }

  .sign {
    width: 670rpx;
    height: 108rpx;
    // border-bottom:1rpx solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);

    text {
      // margin-right: 10rpx;
      display: block;
      font-size: 32rpx;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
    }

    .msg {
      color: #666666;
      // border: 1px solid red;
    }
  }
}
</style>
